#include <func.h>

int main()
{
    int sock_fd=socket(AF_INET,SOCK_STREAM,0);
    ERROR_CHECK(sock_fd,-1,"sock_fd");

    struct sockaddr_in serAddr;
    memset(&serAddr,0,sizeof(serAddr));
    serAddr.sin_family=AF_INET;
    serAddr.sin_addr.s_addr=inet_addr("192.168.74.128");
    serAddr.sin_port=htons(2000);

    int ret;
    ret=bind(sock_fd,(struct sockaddr*)&serAddr,sizeof(serAddr));
    ERROR_CHECK(ret,-1,"bind");
    listen(sock_fd,10);

    struct sockaddr_in clientAddr;
    int addrLen=sizeof(clientAddr);
    int new_fd=accept(sock_fd,(struct sockaddr*)&clientAddr,&addrLen);
    ERROR_CHECK(new_fd,-1,"accept");

    //
    printf("ip=%s,port=%d\n",inet_ntoa(clientAddr.sin_addr),
    ntohs(clientAddr.sin_port));

    char buf[1000]={0};
    recv(new_fd,buf,sizeof(buf),0);
    printf("server get=%s\n",buf);

    //
    send(new_fd,"world",5,0);
    close(new_fd);
    close(sock_fd);
    return 0;
}